<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateActivesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 活动
        Schema::create('actives', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name')->comment('名称');
            $table->timestamp('active_start_time')->nullable()->comment('活动开始时间');
            $table->timestamp('active_end_time')->nullable()->comment('活动结束时间');
            $table->timestamp('report_end_time')->nullable()->comment('报名截至时间');
            $table->decimal('price',8,2)->default(0)->comment('价格');
            $table->integer('buy_number')->default(0)->comment('人数');
            $table->longText('info')->nullable()->comment('详情');
            $table->string('cover_img')->default('')->comment('封面图');
            $table->string('sponsor')->default('')->nullable()->comment('主办方');
            $table->timestamps();
        });
        // 轮播图
        Schema::create('active_img', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('active_id')->comment('活动')->nullable();
            $table->string('img')->nullable()->comment('图片');
            $table->timestamps();
        });

        // 用户购买的活动；
        Schema::create('user_active', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('active_id')->comment('活动')->nullable();
            $table->integer('user_id')->comment('用户id')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
